import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.nio.channels.DatagramChannel;

public class UDPclient {
    public static void main(String[] args) throws Exception {
        DatagramSocket client=new DatagramSocket(9999);
        byte data[]=new  byte[1024];
        DatagramPacket packet=new DatagramPacket(data,data.length);
        System.out.println("【UDPClient】客户端等待服务端发送消息.....");
        client.receive(packet);
        System.out.println("【UDPClient】接受到消息，消息内容为："+new String(data,0, packet.getLength()));
        client.close();
    }
}
